const mysql = require("mysql");

function query(sql,params=[]){
    return new Promise((resolve,reject)=>{
        const con = mysql.createConnection({
            host:"localhost",
            port:3306,
            user:"root",
            password:"root",
            database:"1803b"
        })
        
        con.query(sql,params,function(err,results){
            if(err){
                reject(err)
            }else{
                resolve(results)
            }
        })
        con.end();
    });

}

module.exports= query;